﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cheenti.UserControls
{
    public partial class TextSlide : System.Web.UI.UserControl
    {
        public string ItemIndex
        {
            get
            {
                return this.ShareIt1.ItemIndex;
            }
            set
            {
                this.ShareIt1.ItemIndex = value;
            }
        }


        public PostType SlideType
        {
            get;
            set;
        }

        private ITemplate _title = null;

        [TemplateContainer(typeof(MessageContainer))]
        public ITemplate title
        {
            get
            {


                return _title;
            }
            set
            {
                _title = value;
            }
        }

        private ITemplate _body = null;

        [TemplateContainer(typeof(MessageContainer))]
        public ITemplate body
        {
            get
            {
                return _body;
            }
            set
            {
                _body = value;
            }
        }

        private ITemplate _footer = null;

        [TemplateContainer(typeof(MessageContainer))]
        public ITemplate footer
        {
            get
            {
                return _footer;
            }
            set
            {
                _footer = value;
            }
        }

        void Page_Init()
        {
            if (_title != null)
            {
                MessageContainer lTitle = new MessageContainer(0);
                _title.InstantiateIn(lTitle);
                this.slideTitle.Controls.Add(lTitle);
            }

            if (_body != null)
            {
                MessageContainer lBody = new MessageContainer(0);
                _body.InstantiateIn(lBody);
                this.slideBody.Controls.Add(lBody);
            }

            if (_footer != null)
            {
                MessageContainer lFooter = new MessageContainer(0);
                _footer.InstantiateIn(lFooter);
                this.slideFooter.Controls.Add(lFooter);
            }

            this.ShareIt1.ShareType = this.SlideType;
            this.ShareIt1.ItemIndex = this.ItemIndex;
        }

        public class MessageContainer : Control, INamingContainer
        {
            private int index;
            internal MessageContainer(int index) { this.index = index; }
            public int Index { get { return index; } }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}